package com.cskaoyan.javase.oop1._12static._3usecase;

/**
 * 用静态成员方法给静态成员变量赋值
 * 但是要注意方法不调用不执行
 *
 * @since 11:21
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        // System.out.println(A.num);
        // 调用静态成员方法会触发类加载
        // A.setNum();
        A a = new A();
        A.setNum();
        System.out.println(A.num);
    }
}

class A {
    static int num = 100;

    public static void setNum() {
        // 复杂的算法
        num = 200;
    }

    public A() {
        num = 300;
    }
}
